#include "../comm.h"
class Solution {
public:
    // 一艘船就两个人，如何最大化利用
    int numRescueBoats(vector<int>& people, int limit) {
        sort(people.begin(), people.end());
        int l = 0, r = people.size() - 1;
        int ans = 0;
        while(l < r)
        {
            if(people[l] + people[r] <= limit) ++l, --r, ++ans;
            else --r, ++ans;
        }
        if(l == r) ++ans;
        return ans;
    }
};